package com.shenmazong.servereduresume.controller;

import com.shenmazong.servereduresume.ossutils.OssUploadTemplate;
import com.shenmazong.utils.ResultResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 幻死
 * @version 1.0
 * @description: TODO
 * @date 2021/9/23 15:09
 */
@RestController
//@CrossOrigin
public class OssController {

    @Autowired
    OssUploadTemplate ossUploadTemplate;

    @PostMapping(value = "uploadFile")
    public ResultResponse uploadFileObjectStorage(MultipartFile file){
        return ossUploadTemplate.uploadFileObjectStorage(file);
    }

    @PostMapping(value = "deleteFile")
    public ResultResponse deleteFileObjectStorage(String filename) {
        return ossUploadTemplate.deleteFileObjectStorage(filename);
    }

    @PostMapping(value = "downloadFile")
    public ResultResponse downloadObjectStorage(String filename) {
        return ossUploadTemplate.downloadObjectStorage(filename);
    }
}
